'use strict'

const readline = require("readline");
var Connection = require('tedious').Connection;

var config = {
    server: 'us.harperdata.com,3098', 
    authentication: {
        type: 'default',
        options: {
            userName: 'HarperdataDBUser',
            password: 'HarperdataDemo'  
        }
    },
    options: {
        // If you are on Microsoft Azure, you need encryption:
        encrypt: true,
        database: 'Harperdata'  //update me
    }
};

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

console.log(`Select a numbers below to change the default value and then press "C" to test connectivity.`);
console.log(`1. Change Server []`);
console.log(`2. Change Port []`);
console.log(`3. Change Provider []`);
console.log(`4. Change Provider []`);
console.log(`5. Change Provider []`);
console.log(`6. Change Provider []`);
console.log(`7. Change Provider []`);

rl.question("Server: ", function (host) {
    rl.question("Login: ", function (login) {
        rl.question("Password: ", function (pwd) {
            console.log(`Attempting login to ${host} using connection string ""`);
            var connection = new Connection(config);

            connection.on('connect', function (err) {
                // If no error, then good to proceed.
                console.log("Connected");
            });

            rl.close();
        });
    });
});

rl.on("close", function () {
    console.log("\nBYE BYE !!!");
    process.exit(0);
});